package com.ajk.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ajk.server.dao.BsTimeBlockDictMapper;
import com.ajk.server.model.BsTimeBlockDict;
import com.ajk.server.model.query.BsTimeBlockDictQuery;
import com.ajk.server.service.BsTimeBlockDictService;

/**
 * 血糖测量点  <br>
 * dict_bs_time_block <br>
 * v1.0 2016-05-01
 */
 @Service
 public class BsTimeBlockDictServiceImpl implements BsTimeBlockDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(BsTimeBlockDictServiceImpl.class);
	
	@Autowired
	private BsTimeBlockDictMapper bsTimeBlockDictMapper;
	
	/**
 	*根据ID删除 血糖测量点
 	*/
 	@Override
 	public Integer deleteBsTimeBlockDictById(Integer id){
 		return bsTimeBlockDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 血糖测量点
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertBsTimeBlockDict(List<? extends BsTimeBlockDict> bsTimeBlockDicts){
		Integer count = bsTimeBlockDictMapper.batchInsert(bsTimeBlockDicts);
		return count;
 	}
 	/**
 	*新增 血糖测量点
 	*/
 	@Override
 	@Transactional
 	public Integer insertBsTimeBlockDict(BsTimeBlockDict domain){
		Integer id = bsTimeBlockDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 血糖测量点
 	*/
 	@Override
 	@Transactional
 	public Integer updateBsTimeBlockDict(BsTimeBlockDict domain){
		Integer count = bsTimeBlockDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 血糖测量点
 	*/
 	public BsTimeBlockDict findBsTimeBlockDictById(Integer id){
 		BsTimeBlockDict result = bsTimeBlockDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 血糖测量点
 	*/
	public List<BsTimeBlockDict> findBsTimeBlockDictByQuery(BsTimeBlockDictQuery query){
		query.dealWith();
		List<BsTimeBlockDict> result = bsTimeBlockDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (BsTimeBlockDict bsTimeBlockDict : result) {
				bsTimeBlockDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countBsTimeBlockDictByQuery(BsTimeBlockDictQuery query){
 		query.dealWith();
 		Integer result = bsTimeBlockDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<BsTimeBlockDict> findBsTimeBlockDictByIds(List<Integer> ids){
 		List<BsTimeBlockDict> result = bsTimeBlockDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (BsTimeBlockDict bsTimeBlockDict : result) {
				bsTimeBlockDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public BsTimeBlockDict findByName(String name){
		BsTimeBlockDict result = bsTimeBlockDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<BsTimeBlockDict> findAll(){
		List<BsTimeBlockDict> result = bsTimeBlockDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (BsTimeBlockDict bsTimeBlockDict : result) {
				bsTimeBlockDict.dealWith();
			}
		}
		return result;
	}
}	